<%@page import="news.entity.Topic"%>
<%@page import="news.dao.impl.TopicDaoImpl"%>
<%@page import="org.news.dao.TopicDao"%>
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'topic_add.jsp' starting page</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->

  </head>
  
  <body>
    <%
    request.setCharacterEncoding("utf-8");
    String tname=request.getParameter("tname");
    TopicDao topicdao=new TopicDaoImpl();
    Topic topic=topicdao.findTopicByname(tname);
    if(topic==null){
    	topicdao.addTopic(tname);
    %>
    <script type="text/javascript">
    alert("当前主题创建成功，点击确认返回主题列表！");
    location.href="admin.jsp";
    </script>
    <%}else{ %>
    <script type="text/javascript">
    alert("当前主题已存在，请重新输入主题！");
    location.href="do_topic_add.jsp";
    </script>
    
   
    
   <%} %> 
  </body>
</html>
